<?php

declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class LakalaWechatPayment extends AbstractMigration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change(): void
    {
        $this->table('lakala_wechat_payment', ['comment' => '拉卡拉微信支付表', 'signed' => false])
            ->addColumn('payment_id', 'integer', ['signed' => false,'comment' => '支付ID'])
            ->addColumn('wechat_transaction_id', 'string', ['comment' => '微信交易ID'])
            ->addColumn('order_state', 'tinyinteger', ['signed' => false,'comment' => '订单状态枚举：(1) 待发货；(2) 已发货；(3) 确认收货；(4) 交易完成；(5) 已退款；(6) 资金待结算。'])
            ->addColumn('goods_desc', 'string', ['limit' => 255,'comment' => '商品描述'])
            ->addColumn('express_company', 'string', ['limit' => 32,'comment' => '快递公司ID'])
            ->addColumn('express_company_name', 'string', ['limit' => 64,'comment' => '快递公司名称'])
            ->addTimestamps('create_time', 'update_time')
            ->addIndex(['payment_id'], ['name' => 'idx_payment_id', 'unique' => true])
            ->addIndex(['wechat_transaction_id'], ['name' => 'idx_wechat_transaction_id', 'unique' => true])
            ->create();
    }
}
